<?php


namespace App\Http\Requests\Partitions;
use Illuminate\Foundation\Http\FormRequest;

class StoreRequest extends FormRequest
{
    /**
     * Determine if the user is authorized to make this request.
     *
     * @return bool
     */
    public function authorize()
    {
        return true;
    }

    /**
     * Get the validation rules that apply to the request.
     *
     * @return array
     */
    public function rules()
    {
        return [
            'data.store_id' => 'required|string',
            'data.partitions' => 'array',
            'data.partitions.*.id' => 'integer|gte:0',
            'data.partitions.*.name' => 'string|max:10',
            'data.partitions.*.partition_tables' => 'array',
            'data.partitions.*.partition_tables.*.id' => 'required|integer',
            'data.partitions.*.partition_tables.*.number' => 'required|string|max:10',
            //'data.partitions.*.partition_tables.*.min' => 'integer',
            'data.partitions.*.partition_tables.*.max' => 'required|string|max:5',
            'data.partitions.*.partition_tables.*.state' => 'required|integer|in:0,1',
        ];
    }

    public function messages()
    {
        return [
            'data.store_id' => '门店ID~',
            'data.partitions' => '区域',
            'data.partitions.*.id.required' => '区域ID必填',
            'data.partitions.*.id.integer' => '区域ID必须为整数',
            'data.partitions.*.id.gte' => '区域ID不可小于0',
        ];
    }
}